/**
 * 
 */
package engine;

import massDistribution.ClassAttributeMap;
import massDistribution.MassDistribution;
import core.FrameOfDiscernment;

/**
 * @author Elisa Costante
 * 
 */
/**
 * @author Elisa Costante
 * 
 */
public class RelationshipManager {

	/**
	 * Compute the relationshipTrust and return it or null if the caller or the
	 * candidateService is null.
	 * 
	 * @param caller
	 * @param candidateService
	 * @param trustConfiguration
	 * @param frameOfDiscernment
	 * @return
	 */
	public static MassDistribution getRelationshipTrust(Service caller,
			Service candidateService, ClassAttributeMap trustConfiguration,
			FrameOfDiscernment frameOfDiscernment) {

		if (caller != null && candidateService != null
				&& caller.getMonitoredServices() != null
				&& caller.getMonitoredServices().contains(candidateService)) {

			Service foundService = (Service) caller
					.getMonitoredService(candidateService.getIdentifierName());
			MassDistribution mass = foundService.getMassDistribution(
					frameOfDiscernment, trustConfiguration);

			return mass;

		} else
			return MassDistribution.getLackOfKnowledge(frameOfDiscernment);

	}
}
